

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>E动国际---注册</title>
    <meta name="keywords" content="mtons,$!{site_keywords}">
    <meta name="description" content="$!{site_description}">
    <!-- v3 -->
    <link rel="stylesheet" href="/irun/assets/vendors/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/irun/assets/css/login.css">
    <link rel="stylesheet" href="/irun/assets/vendors/animate/animate.min.css">

    <!-- JavaScript -->
    <script type="text/javascript" src="/irun/assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="/irun/assets/js/jquery-migrate-1.2.1.min.js"></script>
    <script type="text/javascript" src="/irun/assets/vendors/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/irun/assets/vendors/validate/jquery.validate.min.js"></script>
 	<script type="text/javascript" src="/irun/assets/vendors/validate/messages_zh.min.js"></script>
 	<script type="text/javascript" src="/irun/assets/vendors/layer/layer.js"></script>
    <!-- Favicons -->

</head>
<body class="sign">
<div class="login">
    <a href="/index">
        <img src="/irun/assets/images/logo.png" height="72" width="72">
    </a>
    <h1>E动国际---注册</h1>
    <a href="/login" class="signup-link gapps"><span>已有账号, 登录</span></a>
    <hr>
    <form action="reg" method="post">
        <div id="message">

        </div>
        <label for="id_email">用户名:</label>
        <div id="id_email">
            <input maxlength="18" class="form-control border" name="username" value="" placeholder="用户名" type="text" data-required data-conditional="username" data-description="username" data-describedby="message">
        </div>
        <label for="id_password">密码:</label>
        <div id="id_password">
            <input id="password" class="form-control border" maxlength="18" name="password" placeholder="密码" type="password" data-required>
        </div>
        <label for="id_password2">确认密码:</label>
        <div id="id_password2">
            <input maxlength="18" class="form-control border" name="password2" placeholder="请再输入一次密码" type="password" data-required data-conditional="confirm" data-describedby="message" data-description="confirm">
        </div>
        <input type="submit" class="btn btn-success border" value="注 册">
    </form>
</div>

<script type="text/javascript">
    $(function(){
    	$("form").validate({
    		debug:true,//只验证  不提交
    	    rules: {
    	      username: {
    	        required: true,
    	      },
    	      name: {
    	        required: true,
    	       
    	      },
    	      password: {
    	        required: true,
    	        minlength: 5
    	      },
    	     password2: {
    	        required: true,
    	        equalTo: "#password"
    	      },
    	      email: {
    	        required: true,
    	        email: true
    	      },
    	      
    	      
    	    },
    	    messages: {
    	      
    	      username: {
    	        required: "请输入用户名",
    	        minlength: "用户名"
    	      },
    	      name: {
      	        required: "请输入昵称",
      	      },
    	      password: {
    	        required: "请输入密码",
    	        minlength: "密码长度不能小于 5 个字母"
    	      },
    	      password2: {
    	        required: "请再次输入密码",
    	        equalTo: "两次密码输入不一致"
    	      },
    	      email: "邮箱格式不正确",
    	      
    	     },
    	      errorPlacement:function(error,element) {  
    	    	  element.popover('destroy');
    	    	  element.popover({
    	    		  content:error[0].innerHTML
    	    	  });
    	    	  element.click();
    	    	  element.closest('div').removeClass('has-success').addClass('has-error');
    	   },
    	     success:function(a,b){
    	    	 $(b).parent().removeClass('has-error').addClass('has-success');
    	    	 $(b).popover('destroy');
    	     },
    	     submitHandler: function(form) {   //验证通过执行这里
    	    	var layer1 = layer.msg('正在处理中，请稍后', {
    	    		  icon: 16
    	    		  ,shade: 0.5,
    	    		  time:0,
    	    		});
    	     
    	     
    	    	$.ajax({
    	    		   type: "POST",
    	    		   url: "/public/register",
    	    		   data:$(form).serialize(),
    	    		   success: function(data){
    	    			   layer.close(layer1); 
    	    				if(data.code==100){
    	    					layer.msg('用户已经被占用了', function(){});
    	    				}
    	    				if(data.code==200){
    	    					layer.alert('用户注册成功，2秒后为您跳转到登录页面', {icon: 6});
    	    					setTimeout(function(){
    	    				   window.location.href='/login';		
    	    					},2000);
    	    				
    	    				}
    	    				if(data.code==101){
    	    					layer.msg('邮箱已经使用过，请重新输入！', function(){});
    	    					
    	    				}
    	    		   },
    	    	error:function (XMLHttpRequest, textStatus, errorThrown) {
    	    		layer.close(layer1); 
    	    		layer.msg('服务器通讯错误', {icon: 5});
    	    	}
    	    		});
    	     }  
    	});
   
    })
</script>


    <p class="small">
     <a href="http://www.miitbeian.gov.cn/" target="_blank">
    </p>

    <script type="text/javascript">
        //<!CDATA[
        var bodyBgs = [];
        bodyBgs[0] = "/irun/assets/images/first/bg-1.jpg";
        bodyBgs[1] = "/irun/assets/images/first/bg-2.jpg";
        bodyBgs[2] = "/irun/assets/images/first/bg-3.jpg";
        bodyBgs[3] = "/irun/assets/images/first/bg-4.jpg";
        bodyBgs[4] = "/irun/assets/images/first/bg-5.jpg";
        bodyBgs[5] = "/irun/assets/images/first/bg-9.jpg";
        var randomBgIndex = Math.round( Math.random() * 5 );
        //输出随机的背景图
        document.write('<style>body{background:url(' + bodyBgs[randomBgIndex] + ') no-repeat 100% 0}</style>');
        //]]>
    </script>
</body>
</html>

